package com.libs.xxf.simple.textactivity

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.libs.xxf.simple.R
import com.tools.xxf.updatelib.apkinfo.fragment.GetServerApkFragment
import com.tools.xxf.updatelib.updateapp.UpdateMode
/**
 * TODO: 测试版 ---测试apk更新
 * @author XXF
 * Create Time : 2017/12/8 14:00
 */
class TextUpdate : AppCompatActivity() ,GetServerApkFragment.UpdateFinish{
    override fun updateFinish() {
        // TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_update)

    }

    fun onClick(view: View) {
        when (view.id) {

            R.id.force -> {//强制更新
                GetServerApkFragment.create()
                        .bindModel(UpdateMode.FORCE)
                        .versionMode("debug")//此处查询服务器版本信息需要的参数
                        .build(supportFragmentManager);
            }
            R.id.unforce -> {//非强制更新
                GetServerApkFragment.create()
                        .bindModel(UpdateMode.UNFORCE)
                        .versionMode("debug")//此处查询服务器版本信息需要的参数
                        .build(supportFragmentManager);
            }
            else -> throw IllegalArgumentException("view id = ${view.id} unregistered  click events")
        }
    }
}
